#include "cute.h"
#include "ide_listener.h"
#include "cute_runner.h"
#include "regShapeTest.h"

#include <physics>

using physics::scalar;
using physics::vector;
using physics::Triangle;
using physics::Square;
using physics::Pentagon;

namespace
{

void triangleTest()
{
	Triangle t;
	scalar sum = 0;
	for (int i = 0; i < t.sides; ++i)
	{
		vector c = t.vertices().col(i);
		sum += std::sqrt(arma::as_scalar(arma::sum(c % c)));
	}
	std::cout << t.vertices() << std::endl;
	ASSERT(sum == t.sides);
}

void squareTest()
{
	Square s;
	scalar sum = 0;
	for (int i = 0; i < s.sides; ++i)
	{
		vector c = s.vertices().col(i);
		sum += std::sqrt(arma::as_scalar(arma::sum(c % c)));
	}
	std::cout << s.vertices() << std::endl;
	ASSERT(sum == s.sides);
}

void pentagonTest()
{
	Pentagon p;
	scalar sum = 0;
	for (int i = 0; i < p.sides; ++i)
	{
		vector c = p.vertices().col(i);
		sum += std::sqrt(arma::as_scalar(arma::sum(c % c)));
	}
	std::cout << p.vertices() << std::endl;
	ASSERT(sum == p.sides);
}

void integrateTest()
{

}

void supportTest()
{
	static const uint size = 5;
	Triangle t(2, size);
	vector expected("0 " + std::to_string(size) + " 0");
	ASSERT_EQUALM("Wrong support", 3, arma::as_scalar(arma::sum(expected == t.getSupport("0 1 0"))));
}

} // namespace

cute::suite make_suite_regShapeTest()
{
	cute::suite s;
	s.push_back(CUTE(triangleTest));
	s.push_back(CUTE(squareTest));
	s.push_back(CUTE(pentagonTest));
	s.push_back(CUTE(integrateTest));
	s.push_back(CUTE(supportTest));
	return s;
}
